fix(redis-worker): move unrecoverable queue items to the dead-letter queue#4258
Draft
claude[bot] wants to merge 2 commits into
Draft
fix(redis-worker): move unrecoverable queue items to the dead-letter queue#4258claude[bot] wants to merge 2 commits into
claude[bot] wants to merge 2 commits into
Conversation
…queue SimpleQueue.dequeue() skipped items whose job field was not a string, whose job had no registered schema, or whose payload failed schema validation. Because the queue uses a visibility-timeout redelivery model (items are only removed on ack or by moving them to the DLQ), these skipped items were re-scored and redelivered on every visibility-timeout cycle indefinitely. These failures are unrecoverable, so route all three branches to moveToDeadLetterQueue() instead of silently skipping. Add tests covering the unknown-job and unparseable-payload cases.
🦋 Changeset detectedLatest commit: 6eefa5c The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
SimpleQueueuses a visibility-timeout redelivery model: a dequeued item is re-scored and left in the sorted set, and it only leaves the queue when it is acked or moved to the dead-letter queue (DLQ).Before: When
SimpleQueue.dequeue()encountered an item it could not process — one whosejobfield was not a string, one whosejobhad no registered schema, or one whose payload failed schema validation — it logged an error and skipped the item. Because nothing removed it, the item was re-scored and redelivered on the next visibility-timeout cycle, and this repeated on every cycle indefinitely (a poison-message loop).After: Each of these three cases is unrecoverable — retrying cannot make the item's job or payload valid — so on first encounter the item is moved to the dead-letter queue and never redelivered. This mirrors how the max-attempts path in
worker.tsalready handles valid-but-failing handlers.How
In
SimpleQueue.dequeue(), the three "invalid item" branches (non-stringjob, missing schema, failedsafeParse) nowawait this.moveToDeadLetterQueue(id, <reason>)beforecontinue, instead of only logging and skipping.moveToDeadLetterQueueremoves the item from the main queue and records its payload and the error in the DLQ. The existing error logs are kept for context.✅ Checklist
Testing
Added tests in
packages/redis-worker/src/queue.test.tscovering the unknown-job and unparseable-payload cases: each asserts the item is moved to the DLQ, the main queue is emptied, and the item does not resurface on a subsequentdequeue().Changelog
SimpleQueue.dequeue()now moves unrecoverable items (invalid job field, unknown job schema, or payload that fails schema validation) to the dead-letter queue on first encounter instead of logging and silently re-queuing them, preventing an indefinite redelivery loop.Screenshots
N/A
💯
Generated by Claude Code